Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

able to get inner content by utilizing GetJsonValueByPath #115

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cielavenir
Copy link

these will be possible

double max_tool_speed_rot = object->Get<double>("robot_motion_parameters/max_tool_speed_rot");
string ikTypeName = object->Get<string>("robot_motion_parameters/ikTypeName");
map<string, vector<int>> params = object->Get<map<string, vector<int>>>("robot_motion_parameters/int_parameters");

note that we cannot do object->Get<map<string, map<string, vector<int>>>>("robot_motion_parameters");. This is C++ limitation.


We will use GetJsonValueByPath, so we add leading / to field variable (after copying to temporary variable).

@ziyan
Copy link
Member

ziyan commented Oct 18, 2022

  1. who is the user of this?
  2. so much small std::string copy and creation

if(path[0]!='/') {
path = std::string("/")+field;
}
std::string fieldToConstraint = path.substr(1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cielavenir looks pretty inefficient with creating all these strings on the heap, especially when rapidjson doesn't require std::string

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, alternative ideas are:

  1. use GetJsonValueByPath only when field contains "/"
  2. add a new API named GetPath

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added GetPath now

@cielavenir
Copy link
Author

@cielavenir
Copy link
Author

btw I realized std::string fieldToConstraintForCallGet = path.substr(1, path.find('/', 1)); is better, please tell me such matter(s) /cc @lazydroid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants